package com.shanwen.shopping.adapter;

import android.content.Context;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonAdapter;
import com.shanwen.shopping.R;
import com.shanwen.shopping.entity.GoodsInfo;
import com.shanwen.shopping.imageload.ImageLoadByPicasso;
import com.shanwen.shopping.utils.Utils;

import java.util.List;

/**
 * 商品列表适配器
 */
public class GoodsAdapter extends CommonAdapter<GoodsInfo> {
    private Context mContext;
    public GoodsAdapter(Context context, int layoutResId, List<GoodsInfo> data) {
        super(context, layoutResId, data);
        this.mContext = context;
    }

    @Override
    public void onUpdate(BaseAdapterHelper helper, GoodsInfo item,int position) {
        helper.setImageLoad(new ImageLoadByPicasso())
                .setImageUrl(R.id.goods_item_cover,item.getCoverUrl())
                .setText(R.id.goods_item_price, Utils.formatPrice(item.getSalePrice()))
                .setText(R.id.goods_item_intro,item.getTitle());
    }


}
